package me.tonywang.security.authentication;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

public class UserSignAuthenticationToken extends AbstractAuthenticationToken {

    private final Object username;
	private Object sign;

	public UserSignAuthenticationToken(Object principal, Object credentials) {
		super(null);
		this.username = principal;
		this.sign = credentials;
		setAuthenticated(false);
	}


	public UserSignAuthenticationToken(Object principal, Object credentials,
			Collection<? extends GrantedAuthority> authorities) {
		super(authorities);
		this.username = principal;
		this.sign = credentials;
		super.setAuthenticated(true); // must use super, as we override
	}

    @Override
    public Object getCredentials() {
        return sign;
    }

    @Override
    public Object getPrincipal() {
        return username;
    }

}
